<?php

use App\Models\Company;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Class CreateCompaniesTable.
 */
class CreateCompaniesTable extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('companies', function (Blueprint $table) {
			$table->increments('id');
			$table->unsignedBigInteger('owner_id')->nullable();
			$table->string('name')->unique();
			$table->string('code')->unique();
			$table->string('address')->nullable();
			$table->timestamps();
		});
		$company = new Company();
		$company->name = '广西北港新材料有限公司';
		$company->code = 'bgxcl';
		$company->address = '广西北海市铁山港区工业园区四号路与七号路交汇处';
		$company->save();
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('companies');
	}
}
